{include file="public/layout" /}
<style type="text/css">
    .ncap-form-default dt.tit em.none{
        display: none;
    }
</style>
<body class="bodystyle" style="cursor: default; -moz-user-select: inherit; min-width:400px;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page min-hg-c-10" style="min-width: 400px;">
    <!-- 操作说明 -->
    <div id="" class="explanation mb15">
        <ul>
            <li><span style="color: red;">注意：微信公众号类型必须是认证服务号</span></li>
        </ul>
    </div>
    <div class="flexigrid">
        <form class="form-horizontal" id="postWechatForm">
            <input type="hidden" name="pay_id" value="{$Config.pay_id}">
            <div class="ncap-form-default">
                <dl class="row">
                    <dt class="tit">
                        <label>支付功能</label>
                    </dt>
                    <dd class="opt">
                        <label class="curpoin"><input id="is_open_wechat0" name="pay_info[is_open_wechat]" value="0" type="radio" {if condition="!isset($pay_info.is_open_wechat) || empty($pay_info.is_open_wechat)"} checked="checked"{/if}>开启</label>
                        &nbsp;
                        <label class="curpoin"><input id="is_open_wechat1" name="pay_info[is_open_wechat]" value="1" type="radio" {if condition="isset($pay_info.is_open_wechat) && $pay_info.is_open_wechat == 1"} checked="checked"{/if}>关闭</label>
                    </dd>
                </dl>
                <!-- <dl class="row">
                    <dt class="tit">
                        <label>支付终端</label>
                    </dt>
                    <dd class="opt">
                        <ul class="nc-row ncap-waybill-list">
                            <li style="width: 100%;">
                                <label class="label">
                                    <input class="check" type="checkbox" name="pay_terminal[]" value="1" {if condition="in_array(1, $Config.pay_terminal)"} checked="checked" {/if}>电脑端
                                </label>
                                &nbsp; &nbsp;
                                <label class="label">
                                    <input class="check" type="checkbox" name="pay_terminal[]" value="2" {if condition="in_array(2, $Config.pay_terminal)"} checked="checked" {/if}>手机浏览器
                                </label>
                                &nbsp; &nbsp;
                                <label class="label">
                                    <input class="check" type="checkbox" name="pay_terminal[]" value="3" {if condition="in_array(3, $Config.pay_terminal)"} checked="checked" {/if}>手机端微信
                                </label>
                            </li>
                        </ul>
                    </dd>
                </dl> -->
                <dl class="row">
                    <dt class="tit">
                        <label for="username"><em class="em_empty {notempty name='$pay_info.is_open_wechat'} none {/notempty}">*</em>微信AppId</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="pay_info[appid]" id="appid" value="{$pay_info.appid|default=''}" class="input-txt" autocomplete="off">
                        <p class="notic">请输入您的微信公众平台中的微信AppId，用于微信支付。</p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="username"><em class="em_empty {notempty name='$pay_info.is_open_wechat'} none {/notempty}">*</em>微信商户号</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="pay_info[mchid]" id="mchid" value="{$pay_info.mchid|default=''}" class="input-txt" autocomplete="off">
                        <p class="notic">请输入您的微信公众平台中的微信商户号，用于微信支付。</p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="username"><em class="em_empty {notempty name='$pay_info.is_open_wechat'} none {/notempty}">*</em>微信KEY值</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="pay_info[key]" id="key" value="{$pay_info.key|default=''}" class="input-txt" autocomplete="off">
                        <p class="notic-pic"><img src="__SKIN__/images/pay_info_key.jpg" width="535"></p>
                    </dd>
                </dl>
                <dl class="row">
                    <div class="bot" style="padding-bottom:0px;">
                        <a href="JavaScript:void(0);" onclick="wechatset();" class="ncap-btn-big ncap-btn-green" id="submitWechatBtn">确认提交</a>
                        &nbsp;<a href="JavaScript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=8829&origin_eycms=1','微信支付配置教程')" style="font-size: 12px;padding-left: 10px;position:absolute;top: 30px">不会配置？</a>
                    </div>
                </dl>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

    $(function(){
        $("input[name='pay_info[is_open_wechat]']").click(function(){
            if(1 == $(this).val()){
                $('.em_empty').hide();
            } else {
                $('.em_empty').show();
            }
        });
    });

    /*微信支付配置*/
    function wechatset(){
        var is_open_wechat = $("#postWechatForm input[name='pay_info[is_open_wechat]']:checked").val();
        if (is_open_wechat == 0) {
            if ($('#postWechatForm input[id=appid]').val() == '') {
                layer.alert('微信AppId不能为空！', {icon: 2, title: false});
                return false;
            }

            if ($('#postWechatForm input[id=mchid]').val() == '') {
                layer.alert('微信商户号不能为空！', {icon: 2, title: false});
                return false;
            }

            if ($('#postWechatForm input[id=key]').val() == '') {
                layer.alert('微信KEY值不能为空！', {icon: 2, title: false});
                return false;
            }
        }
        layer_loading('正在处理');
        $.ajax({
            url: "{:url('PayApi/save_pay_api_config', ['_ajax'=>1])}",
            type: 'POST',
            dataType: 'JSON',
            data: $('#postWechatForm').serialize(),
            success: function(res){
                layer.closeAll();
                if (1 == res.code) {
                    var _parent = parent;
                    _parent.layer.close(parentObj);
                    _parent.layer.msg(res.msg, {shade: layer_shade, time: 1000});
                } else {
                    showErrorAlert(res.msg);
                }
            },
            error: function(e){
                layer.closeAll();
                showErrorAlert(e.responseText);
                return false;
            }
        });
    }
</script>
{include file="public/footer" /}